<?php

class ArticleModel extends Model {

    // 自动验证设置
    protected $_validate = array(
        array('name','require', '标题必须！'),
        array('content','check_length','主体内容不得少于20字符',0,'callback'),
        array('content','require','内容必须！'), 
        array('type','require','类型必须！'),
    //    array('type','check_link','转载文章链接不正确!',0,'callback'),
    ); 
     protected $_auto	 =	 array(
	array('create_time','time',1,'function'),
	array('content','stripslashes',1,'function'),
	array('content','htmlspecialchars',1,'function'),
    );

    public function check_length($data){
           if(strlen($data)<20){
                return false;
           }else{
                return true;
           }
     }
   public function check_link($data){
       $rule = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
        if($data==2 && $_POST['link']!='' && preg_match($rule,$data)){
             return true;  
        }else{ 
              return false;  
        } 
   }
}

?>